#exerc3.py 读取“xiaofei.csv”文件中的内容，要求用户输入省份和需要查找的项目，显示相应的结果

cp = input("请输入您要查询的城市和项目已逗号分隔:")
cp = cp.split(",")

fr = open("xiaofei.csv", 'r')
ls = []
#print(fr.read())

for line in fr:
    line = line.replace("\n", '')
    ls.append(line.split(","))

ls1 = []
for i in range(len(ls)):
    for j in range(len(ls[i])):
        for c in cp:
            if c == ls[i][j]:
                if j == 0:
                    print("你输入的城市是:{}".format(ls[i][j]))
                    i1 = i
                    ls1.append(i1)
                    print(ls1)
                    break
                elif j != 0:
                    a = ls1[0]
                    print("{}的消费金额为:{}".format(ls[i][j], ls[a][j]))






